package epidemic;

public class Vec {
	public double x, y;
	
	public Vec() {
		this.x = 0;
		this.y = 0;
	}
	
	public Vec(double x, double y) {
		this.x = x; 
		this.y = y;
	}
	
	public Vec add(Vec other) {
		return new Vec(this.x + other.x, this.y + other.y);
	}
	
	public Vec sub(Vec other) {
		return new Vec(this.x - other.x, this.y - other.y);
	}
	
	public Vec mul(double k) {
		return new Vec(this.x * k, this.y * k);
	}
	
	public double length() {
		return Math.sqrt(x*x + y*y);
	}
	
	public Vec unit() {
		double len = 1 / this.length();
		return new Vec(x * len, y * len);
	}
	
	public Vec normal() {
		return new Vec(-y, x);
	}
	
	public double dot(Vec other) {
		return this.x * other.x + this.y * other.y;
	}
	
	public double cross(Vec other) {
		return this.x * other.y + this.y * other.x;
	}
}
